<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改flink任务配置')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-config-edit" th:object="${jobConfig}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">任务名称：</label>
                <div class="col-sm-8">
                    <input name="jobName" th:field="*{jobName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">提交模式：</label>
                <div class="col-sm-8">
	                <select name="deployMode" class="form-control m-b"
							th:with="type=${@dict.getType('flink-config-deployMode')}">
							<option th:each="dict : ${type}" th:text="${dict.dictLabel}"
								th:value="${dict.dictValue}" th:field="*{deployMode}"></option>
						</select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">sql语句：</label>
                <div class="col-sm-8">
                    <textarea name="flinkSql" class="form-control">[[*{flinkSql}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">flink运行配置：</label>
                <div class="col-sm-8">
                    <textarea name="flinkRunConfig" class="form-control" required>[[*{flinkRunConfig}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">checkPoint配置：</label>
                <div class="col-sm-8">
                    <textarea name="flinkCheckpointConfig" class="form-control">[[*{flinkCheckpointConfig}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">udf地址：</label>
                <div class="col-sm-8">
                    <textarea name="extJarPath" class="form-control">[[*{extJarPath}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">运行后的任务id：</label>
                <div class="col-sm-8">
                    <input name="jobId" th:field="*{jobId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">版本号：</label>
                <div class="col-sm-8">
                    <input name="version" th:field="*{version}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">任务状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box"
						th:each="dict : ${@dict.getType('flink-config-status')}">
						<input type="radio" th:id="${dict.dictCode}" name="status"
							th:value="${dict.dictValue}" th:field="*{status}"> <label
							th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
					</div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">是否开启：</label>
                <div class="col-sm-8">
	                <label class="toggle-switch switch-solid"> 
	                	<input type="checkbox" id="isOpen"
									th:checked="${jobConfig.isOpen == 1 ? true : false}"> <span></span>
					</label>
                </div>
            </div>
            
<!--             <div class="form-group">    
                <label class="col-sm-3 control-label">最后一次启动时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="lastStartTime" th:value="${#dates.format(jobConfig.lastStartTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">最后一次日志：</label>
                <div class="col-sm-8">
                    <input name="lastRunLogId" th:field="*{lastRunLogId}" class="form-control" type="text">
                </div>
            </div> -->


        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "flink/config";
        $("#form-config-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
            	var isOpen = $("input[id='isOpen']").is(':checked') == true ? 1 : 0;
            	var data = $('#form-config-edit').serializeArray();
            	data.push({"name": "isOpen", "value": isOpen});
                $.operate.save(prefix + "/edit",data);
            }
        }

        $("input[name='lastStartTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>